package io.itit.ecp.admin.provide.action.controller;


import io.itit.ecp.admin.provide.action.resp.LogoResp;
import io.itit.ecp.admin.server.entity.LogoEntity;
import io.itit.ecp.admin.server.service.ILogoService;
import io.itit.grass.common.provide.action.resp.ResultResp;
import io.itit.grass.common.server.utils.ConvertUtils;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * Logo
 */
@RestController
@RequestMapping("/ecp-admin/logo")
@RequiredArgsConstructor
public class LogoController {

    private final ILogoService logoService;

    @GetMapping("get")
    public ResultResp<LogoResp> get(@RequestParam(defaultValue = "1") String id) {
        LogoEntity miniProgram = logoService.getById(id);
        return ResultResp.success(ConvertUtils.convert(miniProgram, LogoResp.class));
    }

    @ApiOperation("编辑")
    @PostMapping("update")
    public ResultResp<Boolean> update(@RequestBody LogoEntity req) {
        return ResultResp.success(logoService.saveOrUpdate(req));
    }
}
